class Boy {
    constructor(){
        console.log("执行构造函数...")
        console.log("test name is " + this.name)
        this.name = '张三'
    }
    @speak("中文")
    run(){
        console.log("language is " + this.language)
        console.log("name is " + this.name)
    }
}

function speak (language) {
    return function(target, key, descriptor) {
        console.log(target)
        console.log(key)
        console.log(descriptor)
        target.name = "李四"
        target.language = language
        return descriptor
    }
}
const luke = new Boy()
luke.run()

/*
    装饰器执行顺序是
        1，装饰器函数
        2，类的构造函数
        3，执行普通函数
    在装饰器中无法修改构造函数中的属性，因为构造函数后执行会覆盖掉
    装饰器是对类进行装饰的

    1, npm install babel-plugin-transform-decorators-legacy
    2, .babelrc  plugins: ['transform-decorators-legacy']
*/


